package com.ssy.lingxi.purchase.controller.tender;

import cn.hutool.core.bean.BeanUtil;
import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.purchase.api.dto.response.tender.SubmitTenderInCheckRecordResponse;
import com.ssy.lingxi.purchase.entity.tender.SubmitTenderInCheckRecord;
import com.ssy.lingxi.purchase.service.tender.ISubmitTenderInCheckRecordService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @menu: 招投标-投标内部状态流转管理
 * 内部状态流转记录管理类
 * @author jw.chen
 * @version 2.0.0
 * @date 2021/3/1
 */
@RestController
@RequestMapping("/purchase/submitTenderInCheckRecord")
public class SubmitTenderInCheckRecordController extends BaseController {

    @Resource
    private ISubmitTenderInCheckRecordService submitTenderInCheckRecordService;

    /**
     * 查询内部审核记录
     * @param submitTenderId 投标id
     */
    @RequestMapping(value = "/getSubmitTenderInCheckRecord", method = RequestMethod.GET)
    public Wrapper<List<SubmitTenderInCheckRecordResponse>> getSubmitTenderInCheckRecord(@RequestParam("submitTenderId") Long submitTenderId) {
        UserLoginCacheDTO sysUser = this.getSysUser();
        List<SubmitTenderInCheckRecord> submitTenderInCheckRecordList = submitTenderInCheckRecordService.getSubmitTenderInCheckRecord(sysUser, submitTenderId);
        List<SubmitTenderInCheckRecordResponse> submitTenderInCheckRecordResponseList = submitTenderInCheckRecordList.stream().map(submitTenderInCheckRecord -> BeanUtil.copyProperties(submitTenderInCheckRecord, SubmitTenderInCheckRecordResponse.class)).collect(Collectors.toList());
        return Wrapper.success(submitTenderInCheckRecordResponseList);
    }
}
